package com.lse_from.config

import org.springframework.boot.web.servlet.MultipartConfigFactory
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.util.unit.DataSize
import javax.servlet.MultipartConfigElement

/**
 * 文件上传大小配置
 *
 * @author 祁雪
 */
@Configuration
class FileMultipartConfig {
    /**
     * 配置文件上传大小
     */
    @Bean
    fun multipartConfigElement(): MultipartConfigElement? {
        val factory = MultipartConfigFactory()
        //  单个数据大小 30MIB
        factory.setMaxFileSize(DataSize.ofBytes(31457280))
        /// 总上传数据大小 500MIB
        factory.setMaxRequestSize(DataSize.ofBytes(524288000))
        return factory.createMultipartConfig()
    }
}